package com.vvv.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vvv.shortlink.project.dao.entity.LinkNetworkStatsDO;
import com.vvv.shortlink.project.dto.req.LinkStatsReqDTO;
import com.vvv.shortlink.project.dto.resp.LinkStatsNetworkRespDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author Dell
* @description 针对表【t_link_network_stats】的数据库操作Mapper
* @createDate 2024-02-21 16:23:00
* @Entity com.vvv.shortlink.project.dao.entity.LinkNetworkStats
*/
public interface LinkNetworkStatsMapper extends BaseMapper<LinkNetworkStatsDO> {

    /**
     * 记录访问设备监控数据
     */
    @Insert("INSERT INTO t_link_network_stats (full_short_url, user_id, date, cnt, network) " +
            "VALUES( #{linkNetworkStats.fullShortUrl}, #{linkNetworkStats.userId}, #{linkNetworkStats.date}, #{linkNetworkStats.cnt}, #{linkNetworkStats.network}) " +
            "ON DUPLICATE KEY UPDATE cnt = cnt +  #{linkNetworkStats.cnt};")
    void monitorShortLink(@Param("linkNetworkStats") LinkNetworkStatsDO linkNetworkStatsDO);

    /**
     * 以网络类型分组，获取范围时间内各网络类型的总访问量pv
     *
     * @param requestParam
     * @return
     */
    List<LinkStatsNetworkRespDTO> listNetworkStatsGroupByNetwork(@Param("requestParam") LinkStatsReqDTO requestParam);

}




